OPC Studio User's Guide and Reference
Unsolicited User Interaction
Concepts > Development Concepts > Development Features > User Interface Features > Unsolicited User Interaction
In This Topic

Introduction

OPC Studio components may, under certain circumstances, display a user interface "by itself", without you having to make a specific method call. Such unsolicited user interaction only happens when the current process is running in user interactive mode, as reported by the Environment.UserInteractive Property. In non-interactive mode, the components assume reasonable default user responses. In addition, you can turn off specific user interactions by setting corresponding parameters in the code.

Usually, these are notifications or confirmations related to conditions that cannot be anticipated upfront, such as the certificate exchange in the OPC UA connection process.

In QuickOPC applications, the component controls the connections and diconnections automatically, and when subscriptions are in effect, also makes re-connections, you - as a developer - cannot generally predict when such user interaction may be needed. In OPC Wizard applications, the OPC UA clients that use your server are in control of connections and disconnections, and the user interaction associated with such connections can also happen at any time.

Interaction Types

There are following situations that may trigger an unsolicited user interaction related to OPC Unified Architecture (OPC UA) operations:

For an OPC UA client, the "peer" is an OPC UA server. For an OPC UA server, the "peer" is an OPC UA client.

There is no unsolicited user interaction related to OPC Classic operations.

Controlling the Interaction

In QuickOPC applications, the individual interaction types can be controlled as follows:

In OPC Wizard applications, the individual interaction types can be controlled as follows:

Interaction Providers

The way OPC Studio presents the unsolicited user interaction depends on the environment your application is running in. There is an interaction provider for each such supported environment. An application developed with OPC Studio interrogates the available interaction providers to see which one should perform the interaction, selects the appropriate interaction provider and then uses it to actually communicate with the user. Following interaction providers are available:

Each interaction provider (except for the Null Interaction Provider) can be turned on or off, and may have additional configurable parameters.

Examples

The example is provided for client-side development (QuickOPC). The same principle can be used with server-side development (OPC Wizard). You will use the EasyUAServer Class instead of the EasyUAClient Class in that case.

.NET

// This example shows how to completely turn off interaction in a console application.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

using System;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.Engine;
using OpcLabs.EasyOpc.UA.OperationModel;

namespace UADocExamples.Interaction
{
    partial class ConsoleInteraction
    {
        public static void TurnOff()
        {
            // Do not implicitly trust any endpoint URLs. 
            EasyUAClient.SharedParameters.EngineParameters.CertificateAcceptancePolicy.TrustedEndpointUrlStrings.Clear();

            // Completely disable the console interaction.
            EasyUAClient.SharedParameters.PluginSetups.FindName("UAConsoleInteraction").Enabled = false;

            // Define which server we will work with.
            UAEndpointDescriptor endpointDescriptor = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer";
            // Require secure connection, in order to enforce the certificate check.
            endpointDescriptor.EndpointSelectionPolicy = UAMessageSecurityModes.Secure;
            
            // Instantiate the client object.
            var client = new EasyUAClient();

            UAAttributeData attributeData;
            try
            {
                // Obtain attribute data.
                // The operation will fail, unless you set up mutual trust using certificate stores.
                attributeData = client.Read(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10853");
            }
            catch (UAException uaException)
            {
                Console.WriteLine("*** Failure: {0}", uaException.GetBaseException().Message);
                return;
            }

            // Display results.
            Console.WriteLine("Value: {0}", attributeData.Value);
            Console.WriteLine("ServerTimestamp: {0}", attributeData.ServerTimestamp);
            Console.WriteLine("SourceTimestamp: {0}", attributeData.SourceTimestamp);
            Console.WriteLine("StatusCode: {0}", attributeData.StatusCode);
        }
    }
}
' This example shows how to completely turn off interaction in a console application.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET .
' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
' a commercial license in order to use Online Forums, and we reply to every post.

Imports OpcLabs.EasyOpc.UA
Imports OpcLabs.EasyOpc.UA.Engine
Imports OpcLabs.EasyOpc.UA.OperationModel

Namespace Interaction
    Partial Friend Class ConsoleInteraction
        Public Shared Sub TurnOff()
            ' Do not implicitly trust any endpoint URLs. 
            EasyUAClient.SharedParameters.EngineParameters.CertificateAcceptancePolicy.TrustedEndpointUrlStrings.Clear()

            ' Completely disable the console interaction.
            EasyUAClient.SharedParameters.PluginSetups.FindName("UAConsoleInteraction").Enabled = False

            ' Define which server we will work with.
            Dim endpointDescriptor As UAEndpointDescriptor = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
            ' Require secure connection, in order to enforce the certificate check.
            endpointDescriptor.EndpointSelectionPolicy = UAMessageSecurityModes.Secure

            ' Instantiate the client object.
            Dim client = New EasyUAClient()

            Dim attributeData As UAAttributeData
            Try
                ' Obtain attribute data.
                ' The operation will fail, unless you set up mutual trust using certificate stores.
                attributeData = client.Read(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10853")
            Catch uaException As UAException
                Console.WriteLine("*** Failure: {0}", uaException.GetBaseException.Message)
                Exit Sub
            End Try

            ' Display results.
            Console.WriteLine("Value: {0}", attributeData.Value)
            Console.WriteLine("ServerTimestamp: {0}", attributeData.ServerTimestamp)
            Console.WriteLine("SourceTimestamp: {0}", attributeData.SourceTimestamp)
            Console.WriteLine("StatusCode: {0}", attributeData.StatusCode)
        End Sub
    End Class
End Namespace

Python

# This example shows how to completely turn off interaction in a console application.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
# a commercial license in order to use Online Forums, and we reply to every post.
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from OpcLabs.EasyOpc.UA import *
from OpcLabs.EasyOpc.UA.Engine import *
from OpcLabs.EasyOpc.UA.OperationModel import *


# Do not implicitly trust any endpoint URLs. We want the user be asked explicitly.
EasyUAClient.SharedParameters.EngineParameters.CertificateAcceptancePolicy.TrustedEndpointUrlStrings.Clear()

# Completely disable the console interaction.
EasyUAClient.SharedParameters.PluginSetups.FindName('UAConsoleInteraction').Enabled = False

# Define which server we will work with.
endpointDescriptor = UAEndpointDescriptor('opc.tcp://opcua.demo-this.com:51210/UA/SampleServer')
# Require secure connection, in order to enforce the certificate check.
endpointDescriptor.EndpointSelectionPolicy = UAEndpointSelectionPolicy(UAMessageSecurityModes.Secure)

# Instantiate the client object.
client = EasyUAClient()

try:
    # Obtain attribute data.
    # The operation will fail, unless you set up mutual trust using certificate stores.
    attributeData = IEasyUAClientExtension.Read(client,
                                                endpointDescriptor,
                                                UANodeDescriptor('nsu=http://test.org/UA/Data/ ;i=10853'))
except UAException as uaException:
    print('*** Failure: ' + uaException.GetBaseException().Message)
    exit()

# Display results.
print('Value: ', attributeData.Value)
print('ServerTimestamp: ', attributeData.ServerTimestamp)
print('SourceTimestamp: ', attributeData.SourceTimestamp)
print('StatusCode: ', attributeData.StatusCode)

print()
print('Finished.')

Interaction and Blocking

All unsolicited user interaction (with exception of rare messages and confirmations related to client application instance certificate checks) has a timeout associated with it, and a default user response is assumed should the user not respond in time. This means that under normal circumstances, the current activity cannot be blocked indefinitely if the user fails to respond. In fact, this behavior also guarantees that the activity will eventually proceed even if the Environment.UserInteractive Property incorrectly claimed that the process is running in user interactive mode. The timeout is configurable by the AcceptNotificationTimeout Property in the UAUserInteractionParameters Class. In order to obtain or modify this parameter, access the UserInteractionParameters Property of EngineParameters Property of EasyUAClient.SharedParameters Property.

Interaction and Licensing

When there is a problem with the license key, or when the trial license runtime expires. Instead, such problems are primarily reported as other errors, using the channels for the programming model used. For example, in Imperative Programming Model, the single-argument method throws an exception, a multiple-argument method returns the error in the Exception Property of the OperationResult Class, or with subscriptions, the error is reported in the Exception Property of the OperationEventArgs Class. It is up to the calling code to handle such situations.

In addition, in Windows Forms applications and certain other Windows desktop application, OPC Studio components display a notification in Windows system tray for certain license-related issues:

 

See Also

Fundamentals

Reference

Examples - Client OPC UA Interaction